home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung / Power-Programmierung (Tewi)(1994).iso / magazine / pctchnqs / 1992 / number2 / vbplay / play.txt < prev    next >
Text File  |  1992-03-24  |  3KB  |  126 lines

  1. Sub Play (pp$)
  2.  n% = 1
  3.  cmds$ = "ABCDEFGLMNOPT<> "
  4.  
  5.  While n% <= Len(pp$)            ' Parse play string into commands
  6.   cmd$ = ""
  7.   Do
  8.    cmd$ = cmd$ + Mid$(pp$, n%, 1)
  9.    If Mid$(pp$, n%, 1) = "M" Then
  10.     n% = n% + 1
  11.     cmd$ = cmd$ + Mid$(pp$, n%, 1)
  12.   End If
  13.   n% = n% + 1
  14.  Loop Until InStr(cmds$, Mid$(pp$, n%, 1)) Or n% > Len(pp$)
  15.  
  16.  ' Initialize starting values
  17.  dot% = 0: QueueNote% = 0
  18.  cmdptr% = 2: tlength% = 0
  19.  
  20.  ' Process command
  21.  Select Case Left$(UCase$(cmd$), 1)
  22.  
  23.   Case "<"
  24.    octave% = octave% - 1
  25.    If octave% < 0 Then octave% = 0
  26.  
  27.   Case ">"
  28.    octave% = octave% + 1
  29.    If octave% > 6 Then octave% = 6
  30.  
  31.   Case "C"
  32.    note% = octave% * 12 + 1
  33.    QueueNote% = -1
  34.  
  35.   Case "D"
  36.    note% = octave% * 12 + 3
  37.    QueueNote% = -1
  38.  
  39.   Case "E"
  40.    note% = octave% * 12 + 5
  41.    QueueNote% = -1
  42.  
  43.   Case "F"
  44.    note% = octave% * 12 + 6
  45.    QueueNote% = -1
  46.  
  47.   Case "G"
  48.    note% = octave% * 12 + 8
  49.    QueueNote% = -1
  50.  
  51.   Case "A"
  52.    note% = octave% * 12 + 10
  53.    QueueNote% = -1
  54.  
  55.   Case "B"
  56.    note% = octave% * 12 + 12
  57.    QueueNote% = -1
  58.  
  59.   Case "O"
  60.    octave% = Val(Right$(UCase$(cmd$), Len(cmd$) - 1))
  61.    If octave% < 0 Then octave% = 0
  62.    If octave% > 6 Then octave% = 6
  63.  
  64.   Case "N"
  65.    note% = Val(Mid$(UCase$(cmd$), 2, 2))
  66.    cmdptr% = cmdptr% + Len(Str$(note%)) - 1
  67.    QueueNote% = -1
  68.  
  69.   Case "T"
  70.    tempo% = Val(Right$(UCase$(cmd$), Len(cmd$) - 1))
  71.    If tempo% < 32 Then tempo% = 32
  72.    If tempo% > 255 Then tempo% = 255
  73.  
  74.   Case "L"
  75.    length% = Val(Right$(UCase$(cmd$), Len(cmd$) - 1))
  76.    If length% < 1 Then length% = 1
  77.    If length% > 255 Then length% = 255
  78.  
  79.   Case "P":  note% = 0
  80.    QueueNote% = 1
  81.  
  82.   Case "M"
  83.    Select Case Mid$(UCase$(cmd$), 2, 1)
  84.     Case "N": mode% = S_NORMAL
  85.     Case "L": mode% = S_LEGATO
  86.     Case "S": mode% = S_STACCATO
  87.     Case "F": bf$ = "F"
  88.     Case "B": bf$ = "B"
  89.    End Select
  90.   End Select
  91.  
  92.   '  If command was note or rest, place in queue
  93.   If QueueNote% Then
  94.    Do
  95.     Select Case Mid$(cmd$, cmdptr%, 1)
  96.      Case "+", "#"
  97.       note% = note% + 1
  98.       cmdptr% = cmdptr% + 1
  99.      Case "-"
  100.       note% = note% - 1
  101.       cmdptr% = cmdptr% + 1
  102.      Case "."
  103.       dot% = dot% + 1
  104.       cmdptr% = cmdptr% + 1
  105.  
  106.      ' Numbers here mean temporary length for current note
  107.  
  108.      Case "0","1","2","3","4","5","6","7","8","9"
  109.       tlength% = Val(Mid$(cmd$, cmdptr%, 2))
  110.       cmdptr% = cmdptr% + Len(Str$(tlength%)) - 1
  111.  
  112.     End Select
  113.    Loop Until cmdptr% > Len(cmd$)
  114.    If tlength% = 0 Then tlength% = length%
  115.    status% = PlayNote(1,note%,tempo%,tlength%,mode%,dot%)
  116.   End If
  117.  Wend
  118.  
  119.  status% = StartSound()           ' Start things going
  120.  
  121.  If bf$ = "F" Then                ' Remain here if user wants
  122.   While CountVoiceNotes(1) > 0    ' foreground mode
  123.   Wend
  124.  End If
  125. End Sub
  126.